package pro.softzhang.algo.lc2300;

import com.alibaba.fastjson.JSON;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 *
 */
public class LC2341_MaximumNumberOfPairsInArray {
    public static void main(String[] args) {
        int[] iarr = new int[]{1,3,2,1,3,2,2};
        System.out.println(JSON.toJSONString(new Solution().numberOfPairs(iarr)));
    }

    /**
     *
     */
    static
    class Solution {
        public int[] numberOfPairs(int[] nums) {
            int count = 0;
            Map<Integer, Integer> m = new LinkedHashMap<>();
            for (int num : nums) {
                if (m.containsKey(num)) {
                    m.remove(num);
                    count++;
                } else {
                    m.put(num, num);
                }
            }
           return new int[]{count, m.size()};
        }
    }
}
